<?php 


/** 
***************************************************
*欢迎使用免费版xSite企业自助建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.php.net.cn/xsite/ 
***************************************************
**/




header("Cache-Control: no-cache, must-revalidate"); header("Content-type: application/json;charset=UTF-8"); require_once "m.inc.php"; $category = empty($_GET['c']) ? empty($_POST['c']) ? '' : $_POST['c'] : $_GET['c']; $callback = empty($_GET['callback']) ? empty($_POST['callback']) ? 'jsonp1' : $_POST['callback'] : $_GET['callback']; if (preg_match('/jsonp([\d]+)$/', $callback, $temp)) { $page = $temp[1]; } $data = array(); $json = array(); if ($category == '' || $category == 'index') { $article_list = tpl_article_list("limit=9&depth=1&page={$page}"); $article_list = $article_list['list']; $product_list = tpl_product_list("limit=9&depth=1&page={$page}"); $product_list = $product_list['list']; if (is_array($article_list) && count($article_list) ) { foreach ($article_list as $k => $v) { $v['module'] = 'article'; $data[$k] = $v; } } if (is_array($product_list) && count($product_list) ) { foreach ($product_list as $k => $v) { $v['module'] = 'product'; $data[$k] = $v; } } krsort($data, SORT_NUMERIC); } else { if (!array_key_exists($category, $system_category)) { echo "{$callback}(" . json_encode($json) . ")"; exit(); } if ($system_category[$category]['module'] == 'page') { if (!file_exists( SITE_ROOT . "/data/setting/{$site_url}/{$category}/index.txt" )) { echo "{$callback}(" . json_encode($json) . ")"; exit(); } $info = tpl_page_details($category); $temp = array(); $temp['t'] = _e(str_sub($info['body_name'], 40, '…'), "没有名字"); $temp['i'] = !empty($info['ptitle']) ? "http://{$site_url}{$site_path}/{$info['ptitle']}?size=400x300" : ''; $temp['u'] = "category={$category}"; $temp['c'] = $category; $temp['p'] = $key = date("Y-m-d H:i:s", filemtime(SITE_ROOT . "/data/setting/{$site_url}/{$category}/index.txt")); $temp['s'] = $info['body_title']; $temp['f'] = $info['seo_author']; $temp['d'] = $site_url; $temp['a'] = ';'; $temp['id'] = $key; $temp['m'] = md5($key); $temp['r'] = substr(md5($key), 0, 8); $temp['k'] = $info['seo_keywords']; $temp['pos'] = 1396231000000+rand(111111,999999); $temp['fm'] = "3"; $temp['idx'] = "0"; $temp['digg'] = 0; $temp['bury'] = 0; $temp['rank'] = "10000"; $json[] = $temp; echo "{$callback}(" . json_encode($json) . ")"; exit(); } if ($system_category[$category]['module'] == 'article') { $article_list = tpl_article_list("category={$category}&limit=18&depth=1&page={$page}"); $article_list = $article_list['list']; if (is_array($article_list) && count($article_list) ) { foreach ($article_list as $k => $v) { $v['module'] = 'article'; $data[$k] = $v; } } } if ($system_category[$category]['module'] == 'product') { $product_list = tpl_product_list("category={$category}&limit=18&depth=1&page={$page}"); $product_list = $product_list['list']; if (is_array($product_list) && count($product_list) ) { foreach ($product_list as $k => $v) { $v['module'] = 'product'; $data[$k] = $v; } } } } foreach($data as $k => $v) { if ($v['module'] == 'article') { $temp = array(); $info = tpl_article_details("category={$v['category']}&key={$v['key']}"); $temp['t'] = _e(str_sub($info['body_name'], 40, '…'), "没有名字"); $temp['i'] = !empty($info['ptitle']) ? "http://{$site_url}{$site_path}/{$info['ptitle']}?size=400x300" : ''; $temp['u'] = "category={$v['category']}&key={$v['key']}"; $temp['c'] = $v['category']; $temp['p'] = date("Y-m-d H:i:s", $v['key']); $temp['s'] = $info['body_title']; $temp['f'] = $info['author']; $temp['d'] = $site_url; $temp['a'] = (rand(10, 100) % 2 == 0) ? 'g' : 'l'; $temp['id'] = $v['key']; $temp['m'] = md5($v['key']); $temp['r'] = substr(md5($v['key']), 0, 8); $temp['k'] = $info['seo_keywords']; $temp['pos'] = 1396231000000+rand(111111,999999); $temp['fm'] = "3"; $temp['idx'] = "0"; $temp['digg'] = 0; $temp['bury'] = 0; $temp['rank'] = "10000"; $json[] = $temp; } if ($v['module'] == 'product') { $temp = array(); $info = tpl_product_details("category={$v['category']}&key={$v['key']}"); $temp['t'] = _e(str_sub($info['name'], 40, '…'), "没有名字"); $temp['i'] = "http://{$site_url}{$site_path}/{$info['ptitle']}?size=400x300"; if (is_array($info['product_pic']) && count($info['product_pic'])) { $i = 0; foreach($info['product_pic'] as $kk => $vv) { if (empty($vv)) { continue; } if ($i >= 2) { break; } $temp['i'] = "{$temp['i']}|http://{$site_url}{$site_path}/{$vv}?size=400x300"; $i++; } } $temp['u'] = "category={$v['category']}&key={$v['key']}"; $temp['c'] = $v['category']; $temp['p'] = date("Y-m-d H:i:s", $v['key']); $temp['s'] = $info['pname']; $temp['f'] = "本站编辑(xSite)"; $temp['d'] = $site_url; $temp['a'] = (rand(10, 100) % 2 == 0) ? 'g' : 'l'; $temp['id'] = $v['key']; $temp['m'] = md5($v['key']); $temp['r'] = substr(md5($v['key']), 0, 8); $temp['k'] = $info['keywords']; $temp['pos'] = 1396231000000+rand(111111,999999); $temp['fm'] = "3"; $temp['idx'] = "0"; $temp['digg'] = 0; $temp['bury'] = 0; $temp['rank'] = "10000"; $json[] = $temp; } } echo "{$callback}(" . json_encode($json) . ")"; ?>